
#pragma once

#include "sglrender.h"
#include "sgldecode.h"

class GdiRender : public SglRender
{

public:

	GdiRender();
	virtual ~GdiRender();

	DWORD GetLastError(VOID) const;

	virtual BOOL Create(HWND hWnd, INT nWidth, INT nHeight, BOOL bFullScreen);
	virtual BOOL BeginDraw();
	virtual BOOL Draw(PBUFFER pBuffer, COLORREF dwBgColor);
	virtual BOOL EndDraw();
	virtual BOOL DrawPixel(INT nX, INT nY, COLORREF dwColor, BYTE byAlpha);
	virtual BOOL Render(LPCRECT pRect);
	virtual VOID Destroy(VOID);

private:

	DWORD		m_LastError;
	HWND		m_Wnd;
	HDC			m_DC;
	HDC			m_Canvas;
	SIZE		m_Size;

	BOOL CleanUp(VOID);
	BOOL ClearDraw(VOID);
	BOOL DrawBuffer(PBUFFER pBuffer, COLORREF dwBgColor);
	BOOL DrawBlock(PBLOCK pBlock, POINT sPos, COLORREF dwBgColor);
	BOOL CreateCanvas(UINT nWidth, UINT nHeight);
	BOOL CreateCanvas(HDC hDC, UINT nWidth, UINT nHeight);
	BOOL PaintToCanvas(LPCVOID pData, POINT sPos, SIZE sSize);
	BOOL PaintToCanvas(HDC hMemDC, LPCVOID pData, POINT sPos, SIZE sSize);
	BOOL PaintToCanvas(HDC hMemDC, HBITMAP hBitmap, LPBITMAPINFO pBmpInfo, LPCVOID pData, POINT sPos, SIZE sSize);

};
